#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1005;

int n, m;
struct Node {
  int x, y;
  int t;
  double p;
  bool operator<(const Node& o) const { return t < o.t; }
} a[N];
double dp[N];
double ans;
bool ok(int i, int j) {
  ll dt = a[i].t - a[j].t;
  ll dx = a[i].x - a[j].x;
  ll dy = a[i].y - a[j].y;
  return dx * dx + dy * dy <= dt * dt;
}
void solve() {
  cin >> n;
  rep(i, 1, n) cin >> a[i].x >> a[i].y >> a[i].t >> a[i].p;
  sort(a + 1, a + n + 1);
  rep(i, 1, n) {
    dp[i] = a[i].p;
    rep(j, 1, i - 1) {
      if (ok(j, i)) dp[i] = max(dp[i], dp[j] + a[i].p);
    }
    ans = max(ans, dp[i]);
  }
  cout << fixed << setprecision(10) << ans << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}